package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class StringToItemTypeConverter implements Converter<String, ItemType> {
    @Override
    public ItemType convert(String s) {
        for (ItemType itemType : ItemType.values()) {
            if(itemType.getCode()== Integer.parseInt(s)){
                return itemType;
            }
        }
        throw new RuntimeException("不合法的数据");
    }


}
